Skip to content

hono: add maxBodyBytes guard for JSON parsing#1493

Open
TheodorNEngoy wants to merge 4 commits intomodelcontextprotocol:mainfrom
TheodorNEngoy:codex/hono-body-limit
Open

hono: add maxBodyBytes guard for JSON parsing#1493
TheodorNEngoy wants to merge 4 commits intomodelcontextprotocol:mainfrom
TheodorNEngoy:codex/hono-body-limit

Conversation

@TheodorNEngoy
Copy link
Copy Markdown

createMcpHonoApp() includes a built-in JSON body parser that currently reads the full request body.

This PR adds a maxBodyBytes option (default: 1_000_000) and enforces it when parsing application/json bodies, returning 413 Payload too large when exceeded. This provides a basic DoS guard while keeping the behavior configurable.

Includes tests + README option docs.

@TheodorNEngoy TheodorNEngoy requested a review from a team as a code owner February 7, 2026 13:15
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 7, 2026

🦋 Changeset detected

Latest commit: 74cfc3e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/hono Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Feb 7, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1493

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1493

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1493

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1493

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1493

commit: 74cfc3e

@TheodorNEngoy
Copy link
Copy Markdown
Author

Added a changeset so this results in a patch bump for @modelcontextprotocol/hono. All checks are green.

Behavior recap: adds maxBodyBytes (default 1_000_000) for JSON parsing in createMcpHonoApp(), returning 413 when exceeded. Happy to tweak the default/shape if you’d prefer.

Copy link
Copy Markdown
Contributor

@felixweinberger felixweinberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - what prompted this PR, is this an issue you actually ran into?

@km-anthropic
Copy link
Copy Markdown

@claude review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants